package component.global.utils
{
	import component.global.manager.StageManager;
	
	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;
	import flash.geom.Point;

	public class PositionUtils
	{
		/**
		 *将<b>obj2</b>的位置赋值给<b>obj1</b>, 并返回<b>obj1</b>对象 
		 * @param obj
		 * @param obj2
		 * @return 
		 * 
		 */		
		public static function setPos(obj1:Object,obj2:Object):*{
			if(obj1.hasOwnProperty("x") && obj2.hasOwnProperty("x")){
				obj1.x = obj2.x;
			}
			
			if(obj1.hasOwnProperty("y") && obj2.hasOwnProperty("y")){
				obj1.y = obj2.y;
			}
			
			return obj1;
		}
		
		public static function setCenter(display:DisplayObject, parent:DisplayObjectContainer = null):void{
			if(parent == null){
				display.x = (StageManager.Instance.stage.stageWidth - display.width)/2;
				display.y = (StageManager.Instance.stage.stageHeight - display.height)/2;
			} else {
				display.x = (parent.width - display.width)/2;
				display.y = (parent.height - display.height)/2;
			}
		}
	}
}